﻿@model news.admin.cyt369.com.services.Models.Document
@{
    Layout = null;
    var plugName = @news.admin.cyt369.com.Areas.NewsAdmin.Models.PlugName.Name;
    var dlgName = this.Context.Request.Query["dlg"];

    var doAuditFunName = PageViewModel.PageFunctionName(this, "do_audit_article", plugName);
    var doAuditDlgName = PageViewModel.ControlID(this, "do_audit_article_dlg", plugName);
    var doSaveAuditResultFunName = PageViewModel.PageFunctionName(this, "do_save_audit_article_result", plugName);
    var auditImageList = PageViewModel.ControlID(this, "audit_img", plugName);
    var northPanel = PageViewModel.ControlID(this, "north_np", plugName);
}
<div class="easyui-layout article-audit-dlg" fit="true">
    <style type="text/css">
        .article-audit-dlg { }
            .article-audit-dlg .image-list {
            }

            .article-audit-dlg .image-item {
                margin-bottom: 20px;
                border: solid 1px #ddd;
            }

                .article-audit-dlg .image-item .img {
                    width: 100%;
                    height: 130px
                }

                .article-audit-dlg .image-item .img-name {
                    color: rebeccapurple;
                    overflow: hidden;
                    height: 20px;
                    line-height: 20px;
                    font-size: 0.8em;
                }

            .article-audit-dlg .doc-body {
                padding: 10px 50px 20px 50px;
            }
            .article-audit-dlg .title {
                margin-top: 15px;
                min-height: 50px;
                line-height: 50px;
                font-size: 2rem;
            }

            .article-audit-dlg .labels {
                height: 45px;
                line-height: 45px;
                margin-bottom: 10px;
                border-bottom: dotted 1px gray;
                display: flex;
                justify-content: space-between;
            }

                .article-audit-dlg .labels .label {
                    color: gray;
                    margin-right: 20px;
                    font-size: 0.8em;
                }

            .article-audit-dlg .summary {
                min-height: 60px;
                line-height: 25px;
                padding: 0px 20px 10px 20px;
                background-color: #f8f8f8;
                font-size: 0.9rem;
                color: gray;
            }

            .article-audit-dlg .content {
                min-height: 600px;
                margin-top: 20px;
                padding: 20px 10px 10px 10px;
                line-height: 25px;
                font-size: 1.1rem;
                padding: 5px;
            }

                .article-audit-dlg .content span {
                    line-height: 25px;
                }

                .article-audit-dlg .content section {
                    width: 100%;
                }

                .article-audit-dlg .content p {
                    text-indent: 30px;
                    line-height: 25px;
                }

                .article-audit-dlg .content img {
                    max-width: 800px;
                }

                .article-audit-dlg .content table {
                    width: 100%
                }
    </style>
    <div data-options="region:'west',split:true,border:false" class="min-scrollbar" style="width:250px;border-right:solid 1px #ddd;padding:10px;">
        @if (Model.Attachments != null)
        {
            <ul id="#@auditImageList" class="image-list">
                @foreach (var item in Model.Attachments)
                {
                    string imgPath = item.ImagePath;
                    if (!string.IsNullOrEmpty(imgPath))
                    {
                        imgPath = string.Format("{0}/{1}", Admin.CYT369.Com.Utility.SystemSettingService.Instance.NewsBucket.HttpURL, imgPath);
                    }
                    <li class="image-item">
                        <img class="img" src="@imgPath" />
                        <div class="img-name">@item.Name</div>
                    </li>
                }
            </ul>
            <script type="text/javascript">
                $(function () {
                    $('#@auditImageList').viewer({
                        url: 'src',
                        hidden: function () {
                            $('#@northPanel').show();
                        },
                        viewed: function () {
                            $('#@northPanel').hide();
                        }
                    });
                });
            </script>
        }
    </div>
    <div data-options="region:'center',border:false" class="min-scrollbar doc-body">
        <div class="title">@Model.Title</div>
        <div class="labels">
            <div>
                <span class="label">修改时间：@Model.ChangedTime.ToString("yyyy年M月d日")</span>
                @if (!string.IsNullOrEmpty(Model.Author))
                {
                    <span class="label">作者：@Model.Author</span>
                }
                @if (string.IsNullOrEmpty(Model.EditorFullName))
                {
                    <span class="label">编辑：@Model.EditorName</span>
                }
                else
                {
                    <span class="label">编辑：@string.Format("{0}({1})", Model.EditorName, Model.EditorFullName)</span>
                }
                @if (Model.IsAds)
                {
                    <span class="label">广告内容</span>
                }
                @if (Model.GotoTarget && !string.IsNullOrEmpty(Model.TargetURL))
                {
                    <span class="label">跳转目标：@Model.TargetURL</span>
                }
            </div>
        </div>
        <div class="summary">@Model.Summary</div>
        @if (Model.DocExt != null)
        {
            <div class="body-content">
                @Html.Raw(Model.DocExt.DocContent);
            </div>
        }
    </div>
    <div id="@northPanel" data-options="region:'south',border:false" style="height:60px;border-top:solid 1px #ddd;">
        <div class="audit-panel">
            <script type="text/javascript">
                function @doAuditFunName () {
                    var dlg = $dlg('@doAuditDlgName');
                    dlg.dialog({
                        title: '审核说明', width: 500, height: 280,
                        closed: false, cache: false, modal: true, maximizable: false, resizable: true,
                        href: '~/@news.admin.cyt369.com.Areas.NewsAdmin.Models.PlugName.Name/Articles/_AuditArticleDlgRemark',
                        onResize: function () {
                            $(this).dialog('center');
                        },
                        buttons: [
                            {
                                text: "审核通过",
                                handler: function () { @doSaveAuditResultFunName (true); },
                                iconCls: "icon-save"
                            }, {
                                text: "审核不通过",
                                handler: function () { @doSaveAuditResultFunName (false); },
                                iconCls: "icon-cancel"
                            }
                        ]
                    });
                }

                function @doSaveAuditResultFunName (result) {
                    var form = $("#@doAuditDlgName").find("form");
                    if (form.form('enableValidation').form('validate')) {
                        var item = form.form_to_json(function (form, item) {
                            item.CanComment = form.find("#CanComment").switchbutton("options").checked;
                        });
                        item.Id = @Model.Id;
                        item.Result = result;
                        $.ajax({
                            url: "~/@news.admin.cyt369.com.Areas.NewsAdmin.Models.PlugName.Name/Articles/DoArticleAudit",
                            type: "POST",
                            data: item,
                            success: function (e) {
                                $('#@doAuditDlgName').dialog('close');
                                $('#@dlgName').dialog('close');
                            },
                            error: function (e) {
                                ShowAjaxError(e);
                            }
                        });
                    }
                }
            </script>
            <div class="Btn auditCssBtn" onclick="@doAuditFunName ()"> 审 核 </div>
            <div class="Btn closeCssBtn" onclick="$('#@dlgName').dialog('close')"> 关 闭 </div>
        </div>
    </div>
</div>